package ciicos.check.service.impl;

import ciicos.check.entity.CheckTaskItemEntity;
import ciicos.check.mapper.CheckTaskItemMapper;
import ciicos.check.model.checktask.CheckTaskPagination;
import ciicos.check.service.CheckTaskItemService;
import ciicos.permission.service.AuthorizeService;
import ciicos.util.GeneraterSwapUtil;
import ciicos.util.ServletUtil;
import ciicos.util.UserProvider;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 巡检任务
 * 版本： V3.2.0
 * 版权：
 * 作者： 产研项目租
 * 日期： 2023-07-26
 */
@Service
public class CheckTaskItemServiceImpl extends ServiceImpl<CheckTaskItemMapper, CheckTaskItemEntity> implements CheckTaskItemService {


    @Autowired
    private GeneraterSwapUtil generaterSwapUtil;

    @Autowired
    private UserProvider userProvider;

    @Autowired
    private AuthorizeService authorizeService;

    @Override
    public QueryWrapper<CheckTaskItemEntity> getChild(CheckTaskPagination pagination, QueryWrapper<CheckTaskItemEntity> checkTaskItemQueryWrapper) {
        boolean pcPermission = true;
        boolean appPermission = false;
        boolean isPc = ServletUtil.getHeader("ciicos-origin").equals("pc");
        if (isPc) {
        }

        return checkTaskItemQueryWrapper;
    }

    @Override
    public CheckTaskItemEntity getInfo(String id) {
        QueryWrapper<CheckTaskItemEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(CheckTaskItemEntity::getId, id);
        return this.getOne(queryWrapper);
    }

    @Override
    public List<CheckTaskItemEntity> getAnomalyListByDate(Date begin, Date end) {

        return this.list(
                new LambdaQueryWrapper<CheckTaskItemEntity>()
                        .eq(CheckTaskItemEntity::getResult,2)
                        .between(CheckTaskItemEntity::getCreatortime,begin,end)
        );
    }


}
